package com.snailct.bpp.router.request;



import com.snailct.bpp.commons.protocol.RespResult;
import com.snailct.bpp.commons.protocol.WSProtocolHolder;
import com.snailct.bpp.service.core.definition.DefaultServiceDefinition;
import org.springframework.util.Assert;

import java.io.ByteArrayInputStream;

/**
 * Created by huangxa on 2016/7/14.
 */
public class CallAWebService {
    private DefaultServiceDefinition wsServiceDefinition;

    public RespResult sendMessage(){
        Assert.notNull(wsServiceDefinition,"DefaultService definition can't be null!");
        try {
            Object[] responses = WSProtocolHolder.getInstance().request(wsServiceDefinition.getServiceAddr(),"execute",wsServiceDefinition.getSendBody(),"http://component");
            if(responses[0]==null){
                System.out.println("调用失败!");
            }
            return new RespResult(RespResult.ReqStatus.OK,null);
        } catch (Exception axisFault) {
            axisFault.printStackTrace();
        }
        return null;
    }

    public DefaultServiceDefinition getWsServiceDefinition() {
        return wsServiceDefinition;
    }

    public void setWsServiceDefinition(DefaultServiceDefinition wsServiceDefinition) {
        this.wsServiceDefinition = wsServiceDefinition;
    }
}
